// 手撕call
Function.prototype.myCall = function(context) {
    context = context || window // null undefined时候，context为全局对象
    context.fn = this // this指向函数实例
    let args = []
    // 从1开始，因为0为context
    for(let i = 1; i < arguments.length; i++) {
        args.push(arguments[i])
    }
    // 函数有返回值，所以需要把执行结果返回
    let result = context.fn(...args)
    delete context.fn
    return result
}
let sayName = function(age) {
    console.log(`myName is ${this.name}，myage is ${age}`)
}
let obj = {
    name: 'zzy'
}
sayName.myCall(obj, 22, 33)